using System;
using UnityEngine;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;
using ResourceApplyStartEventArgs = UnityGameFramework.Runtime.ResourceApplyStartEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Apply")]
    [UnitSurtitle("Start")]
    public sealed class ResourceApplyStart : FrameworkEventUnit<ResourceApplyStartEventArgs>
    {
        protected override int EventId => ResourceApplyStartEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceApplyStart;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ResourcePackPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Count
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput TotalLength
        {
            get;
            private set;
        }


        protected override void Definition()
        {
            base.Definition();
            ResourcePackPath = ValueOutput<string>(nameof(ResourcePackPath));
            Count = ValueOutput<int>(nameof(Count));
            TotalLength = ValueOutput<long>(nameof(TotalLength));
        }

        protected override void AssignArguments(Flow flow, ResourceApplyStartEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(ResourcePackPath, args.ResourcePackPath);
            flow.SetValue(Count, args.Count);
            flow.SetValue(TotalLength, args.TotalLength);
        }
    }
}